/**
 * 
 */
package info.niwota.ziplock;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * @author qiangli
 * 
 */
public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context ctx, Intent intent) {
		if (intent.getAction() != null) {
			if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
				SharedPreferences sp = PreferenceManager
						.getDefaultSharedPreferences(ctx);
				String key = ctx.getText(R.string.settings_boot_toggle_key)
						.toString();
				boolean bootstart = sp.getBoolean(key, false);
				if (bootstart == true) {
					try {
						Notifications.addNotification(ctx);
					} catch (Exception e) {
						if (Debug.DEBUG) {
							e.printStackTrace();
						}
					}
				}
			}
		}
	}
}
